package com.ftg.learn.chapter10;

/**
 * 组数
 *
 * @author kangjx
 * @createTime 2022/7/25
 */
public class LearnString {

    public static void q1() {

//      定义 "" 开辟空间方法  null 没有空间
        String str = new String();
        str = "abc";
        System.out.println(str.length());
        String str1 = new String("abc");

        System.out.println(str1);

        String str2 = new String(new char[]{'a','b','c'});
        System.out.println(str2);

        //强烈建议 (常量池)
        String str3 = "abc";

        System.out.println(str3);

    }

    public void test1(){
        this.q1();
    }

    public boolean myEquals1(String str1,String str2){
//        == 运算符
        return str1 == str2;
    }

    public boolean myEquals2(String str1,String str2){
        return str1.equals(str2);
    }

}
